package com.sias;

import java.lang.reflect.Method;
import java.lang.reflect.UndeclaredThrowableException;

/**
 * @author 吴文杰
 * @version 1.0
 * @since 2023/6/14 22:51
 */
public class $Proxy0 implements A13.Foo {

  private A13.InvocationHandler h;

  public $Proxy0(A13.InvocationHandler h) {
    this.h = h;
  }

  @Override
  public void foo() throws Exception {
    try {
      Method foo = A13.Foo.class.getMethod("foo");
      h.invoke(this, foo, new Object[0]);
    } catch (RuntimeException | Error e) {
      throw e;
    } catch (Throwable e) {
      throw new UndeclaredThrowableException(e);
    }
  }

  @Override
  public int bar() {
    try {
      Method bar = A13.Foo.class.getMethod("bar");
      Object result = h.invoke(this, bar, new Object[0]);
      return (int) result;
    } catch (RuntimeException | Error e) {
      throw e;
    } catch (Throwable e) {
      throw new UndeclaredThrowableException(e);
    }
  }

}
